import { $init, $digest } from '../../lib/page.data'
import { $login, $request, Session } from '../../lib/page.auth'

const { regeneratorRuntime } = global
//获取应用实例
let api = require('../../utils/api.js');
let http = require('../../utils/http.js');
let util = require('../../utils/util.js');

// pages/indexBuyOrder/indexBuyOrder.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    jinri:0,
    leiji:0,
    tuanzhang:0,
    peiwan:0,
    peiwangzhong:0,
    istuanzhang:0,
  
  },
  
  /**
   * 生命周期函数--监听页面加载
   */
  async onLoad(options) {
    var type = options.type;
    this.setData({
      type: type
    })
    if (type == 3) {
      wx.setNavigationBarTitle({
        title: '团长管理'
      })
    }
    if (type == 4) {
      wx.setNavigationBarTitle({
        title: '合伙人管理'
      })
      this.setData({
        istuanzhang: 1
      })
      
    }
    var that = this;
    var token = wx.getStorageSync('token');
    console.log(wx.getStorageSync("user_info"));
    var user_id = wx.getStorageSync("user_info").data.id;
    //请求详情数据
    http.get(api.hehuoren, { token: token, user_id: user_id }, function (res) {
      var order_price = res.data.data;
      if (res.data.code == 1) {
        var jinri = order_price.jinri;
        var leiji = order_price.leiji;
        var tuangzhang = order_price.tuangzhang;
        var peiwan = order_price.peiwan;
        var peiwanzhong = order_price.peiwanzhong;
        var money = order_price.money;
        var hehuoren = order_price.hehuoren;
        that.setData({
          jinri: jinri,
          leiji: leiji,
          tuangzhang: tuangzhang,
          peiwan: peiwan,
          peiwanzhong: peiwanzhong,
          money: money,
          hehuoren: hehuoren,
        });
      }
      else {
        util.msg('请求接口失败！');
      }
    }, "请求中...");


  },


  

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})